﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Infinity.Common;
using Infinity.Types;
using Infinity.Types.Extensions;
using NUnit.Framework;

namespace Infinity.Tests.Types
{
	public class LazySetTestClass
	{
		private static void Write<T>(IEnumerable<T> enumerable)
		{
			Console.WriteLine();
			Console.WriteLine(string.Join(", ", enumerable));
		}

		[Test]
		public void FuncLazySetTest()
		{
			Assert.Catch(() => new LazySet<int>(null, null, null));

			Write(new LazySet<int>(Enumerable.Range(2, 1000), x => x % 3 == 1));
			Write(Enumerable.Range(0, 1000).ToLazySet(x => x % 2 == 0 && x % 3 == 0));
			Console.WriteLine(string.Join("", "Hello World!".ToLazySet(char.ToLower, _ => true)));

			Write(new LazySet<int, int, string>(tuple => string.Format("({0}, {1})", tuple.Item1, tuple.Item2),
			                                    from i in Enumerable.Range(0, 100)
			                                    from j in Enumerable.Range(0, 100)
			                                    select new Tuple<int, int>(i, j)
				      ));
		}
	}
}